/**
 * @fileOverview
 * todo 这文件干嘛使的
 * @author iNahoo
 * @since 2017/12/15.
 */
"use strict";

const Koa = require('koa');
const app = new Koa();
const fs = require('fs');

const content = fs.readFileSync('./template.jsp','utf-8');
const compile = function(template){
    return function(object){
        return template.replace(/<%=[a-zA-Z0-9]+=%>/g,function(matches,index,originString){
            const key = matches.slice('<%='.length,-'=%>'.length);
            const value =  object[key];
            return value;
        });
    };
};

const getHTML = compile(content);

app.use(async ctx=>{
    ctx.body = getHTML({
        time:new Date().toDateString(),
        string:'hehe',
        JSscription:'console.log($)',
    });
});

app.listen('43765');
